Log In  
BBS > Lexaloffle Community Superblog
This is a combined feed of all Lexaloffle user blogs. For Lexaloffle-related news, see @zep's blog.

All | Following | PICO-8 | Voxatron | General | Off-site
[ :: Read More :: ]

Hi, everyone. I made a very simplistic scene manager for you all to use, its somewhat compressed as well. here's an example:

Cart #scenemanager_sample-0 | 2019-02-03 | Code ▽ | Embed ▽ | No License

Basically, this scene manager allows you to create init, update and draw for each scene (as well as anything else you want to cook up, of course).

HOW TO USE
to make a new scene, use the command 'nscn' inside of your init function. for example: nscn({init=function() end, update=function() end, draw=function() end})

to grab the current scene thats running so you can modify it or its variables, you can simply create a local variable called 'self'.

local this=scn['self']()

(or local this=scn.self())

to switch to a scene, you'll need to comment the ID of that scene so you don't lose track. I recommend you have a function that launches at the init() of your game that creates all of your scenes for you.

command to load a scene: scn_mng.go(id) where id is the scene number you want to run.

Finally, you need to put the 2 commands inside draw() and update(). in update(), put scn_mng.update() and in draw put scn_mng.draw()

code snippit:

--scene manager
--shooting★
scn = {self=function() return scn[scn_mng.r] end} scn_mng = { go=function(s) scn_mng.r = s scn[s].init() end, draw=function() scn[scn_mng.r].draw() end, update=function() scn[scn_mng.r].update() end } function nscn(d) local a={ init=d.init or function() end, update=d.update or function() end, draw=d.draw or function() end } add(scn, a) end

code example (used in cart above)

--sample

function create_scenes()
    --scene 1
    nscn({
        init=function()
            --create a local var called
            --this and set it to self
            --scene
            local this=scn['self']()

            --create particles
            this.particles = {}
            for i=0,16 do
                local a={rnd(127),rnd(127),rnd(2)}
                add(this.particles, a)
            end

            --create a timer to switch
            --to scene 2 with
            this.timer=0
        end,

        update=function()
            --create a local var called
            --this and set it to self
            --scene
            local this=scn['self']()

            this.timer+=1

            if this.timer==120 then
                this.timer=0
                --switch to scene 2
                scn_mng.go(2)
            end
        end,

        draw=function()
         --create a local var called
            --this and set it to self
            --scene
            local this=scn['self']()

            --draw particles
            for i=1,#this.particles do
                pset(this.particles[i][1],
                     this.particles[i][2],
                     7)
            this.particles[i][1]+=this.particles[i][3]
            this.particles[i][2]+=this.particles[i][3]
            end
        end
    })

    --scene 2
    nscn({
        init=function()
            --create a local var called
            --this and set it to self
            --scene
            local this=scn['self']()

            this.timer=0
        end,

        update=function()
            --create a local var called
            --this and set it to self
            --scene
            local this=scn['self']()

            this.timer+=1

            if this.timer==120 then
                this.timer=0
                --switch back to scene 1
                scn_mng.go(1)
            end
        end,

        draw=function()
            cls(1)
        end
    })
end

function _init()
    --create scenes
    create_scenes()
    scn_mng.go(1)
end

function _update()
    scn_mng.update()
end

function _draw()
    cls()
    scn_mng.draw()
    print('running scene '..scn_mng.r, 0, 0, 7)
end
P#61476 2019-02-03 02:34
[ :: Read More :: ]

I am interested in the future making a game (not even sure if it would be in Unity, Game Maker, Godot, or something else) and having some dusty arcade cabinet that you find - and it has a Pico-8 arcade game on it!

I am wondering how feasible it is for the Pico-8 game to be embedded and how well the game canvas could be moved around and positioned, incorporated into the game, to look like it's in a cabinet, etc., or if it's even possible at all.

P#61475 2019-02-03 01:33 ( Edited 2019-02-03 01:44)
[ :: Read More :: ]

Cart #space_race-3 | 2019-02-17 | Code ▽ | Embed ▽ | No License
2

its gonna be a race

update:I added more sattelites and a cow (very productive I know).
Still thinking about the gameplay, I think I am going to make them be able to bump into eachother and collide with astroids and maybe sattelites aswell. and when they eventually get to the moon. maybe do a moonlander mini-game or something.

P#61474 2019-02-03 00:35 ( Edited 2019-02-17 23:07)
[ :: Read More :: ]

Hi all,

I'm writing a short graphical text adventure for the PICO-8, and a few weeks ago I determined that I needed a vector graphics editor capable of outputting PICO-8 code. I've created a web app called GMagic that lets you make vector drawings on a canvas, then export Lua functions for drawing them. I also provide the functions for drawing polygons and polylines:

ptstr() (needed for the functions):

function ptstr(s)
    local data={}
    local wip=''
    for i=1,#s do
        r=sub(s,i,i)
        if(r==',') then
            add(data,wip+0)
            wip=''
        else
            wip=wip..r
        end
    end
    add(data,wip+0)
    return data
end

Polygon:

function poly(r,c,p)
    local t=ptstr(r)
    --based off alienryderflex.com/polygon_fill
    --t=table x1,y1,x2,y2...
    --c=colors (hex)
    --p=pattern
    local pc=#t/2
    local px={}
    local py={}
    local my=127--miny
    local xy=0  --maxy
    --split out xy lookups
    for i=1,#t-1,2 do
        add(px,t[i])
        add(py,t[i+1])
        if(t[i+1]<my) my=t[i+1]
        if(t[i+1]>xy) xy=t[i+1]
        if(i<#t-2) then
            if(p) fillp(p)
            line(t[i],t[i+1],t[i+2],t[i+3],c)
            fillp()
            --yield()
        end
    end
    --scan down the screen
    for y=my,xy do
        local nx={}
        --build a list of nodes
    local n=0
    local j=pc
    for i=1,pc do
        if((py[i]<y and py[j]>=y)
            or(py[j]<y and py[i]>=y)) then
            add(nx,(px[i]+(y-py[i])/(py[j]-py[i])*(px[j]-px[i])))
        end
        j=i
    end
    --bubblesort nodes
    local k=1
    while(k<#nx) do
        if(nx[k]>nx[k+1]) then
            nx[k],nx[k+1]=nx[k+1],nx[k]
            if(k>1) then
                k-=1
            end
        else
            k+=1
        end
    end
    --fill the pixels
    for l=1,#nx-1,2 do
        local d=nx[l]
        local e=nx[l+1]
        if(d>=127) break
        if(e>0) then
            if(d<0) d=0
            if(e>127) e=127
            if(p) fillp(p)
            line(d,y,e,y,c)
            fillp()
        end
    end
 end
 --yield()
end


Polyline:

function pline(r,c,p)
    local t=ptstr(r)
    for i=1,#t-2,2 do
        if(p) fillp(p)
        line(
            t[i],
            t[i+1],
            t[i+2],
            t[i+3],
            c
        )
        fillp()
    end
    --yield()
end

If you want to read more about GMagic or check out some sample screenshots, you can view the Github repository here. If you end up using GMagic for a cart, I'd love to hear about it!

EDIT 6/24: I can't believe I forgot to include ptstr()! I've added it above, and to the Lua sample in the repo.

P#61467 2019-02-02 18:26 ( Edited 2019-06-24 21:48)
[ :: Read More :: ]

Cart #hilda-1 | 2019-02-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
15

The game is a work in progress, but is mechanically complete. Just adding levels and polish at this point.

EDIT: I've got 6 levels so far. I'm going for maybe 10-15, and then I want to add some more SFX and music.

P#61464 2019-02-02 16:22 ( Edited 2019-02-17 04:32)
[ :: Read More :: ]

Modified previous work to add a centroid bar to spiral galaxies.
https://en.wikipedia.org/wiki/Barred_spiral_galaxy

Press: "x" to regenerate.

Cart #galaxy_generator-3 | 2019-02-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

P#61460 2019-02-02 10:55 ( Edited 2019-02-02 11:15)
[ :: Read More :: ]

Cart #rupiwpge-0 | 2019-02-02 | Code ▽ | Embed ▽ | No License
4

This is a work in progress randomly generated marble game. I have to shout out Eggnog, who made the excellent game PicoPutt. You should go play that, this game is only possible because of his excellent collision methods, and it's not nearly as good.

P#61457 2019-02-02 06:26
[ :: Read More :: ]

Cart #zapemediwa-0 | 2019-02-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#61452 2019-02-02 00:27
[ :: Read More :: ]

Cart #adpz-0 | 2019-02-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

It's an implementation in pico-8 of the famous puzzle game,
with one of the most beloved rulesets amongst the game's enthusiasts.

WIP.

P#61447 2019-02-01 21:09
P#61444 2019-02-01 20:31 ( Edited 2019-03-03 00:04)
[ :: Read More :: ]

Cart #flowerhead-1 | 2019-02-07 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
7

A difficult platforming game with a gardening/Splatoon-like twist. Made by Charlie Tran

This is one of my first games, and my longest to date. Please let me know what you think, thanks!

P#61439 2019-02-01 18:54 ( Edited 2019-02-07 00:26)
[ :: Read More :: ]

Cart #salahachider-3 | 2022-09-28 | Code ▽ | Embed ▽ | No License
7


The STG like "LIFE FORCE".
Japanese title is "沙羅曼蛇".

I refferred to Family computer ver.

Main game is WIP.

  • ver 0.04:
    • Adjusted for PICO-8 0.2.5.
    • Title rendering no longer causes a processing drop.
    • Two fighters now appear.
    • Self-destruct.
  • ver 0.03: Stabilize sfx.(using music())
  • ver 0.02: Can shot the bullet. Power up, The players remaining number UI.
  • ver 0.01: Release.
P#61434 2019-02-01 15:17 ( Edited 2022-09-28 16:01)
[ :: Read More :: ]

Cart #lighthouse-0 | 2019-02-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

A tweetcart I made to teach myself what sin() and cos() actually do. I never took trigonometry.

P#61430 2019-02-01 09:54 ( Edited 2019-02-01 09:56)
[ :: Read More :: ]

Cart #picochallenge-0 | 2019-02-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

A demake of my game Patrick's Cyberpunk Challenge for the TweetTweetJam.

The object of the game is to move Patrick the Leprechaun around the board and remove all 28 squares. Squares with special symbols will remove extra squares:

Move Patrick to a square using the arrow keys. Note that you can (and sometimes must) move diagonally by pressing two arrow keys simultaneously.

Puzzles might be impossible to solve, and the game doesn't recognize if you win or lose. If the screen is empty except for Patrick, you win! If you have no legal moves, you lose and must restart the game manually.

Source code:

poke(24364,3)x="웃"v="▥"h="▤"b={}for i=1,36 do b[i]=i%9<2 and""or"█"end for i in all{"⬆️","➡️",h,"⬅️","⬇️",v,x}do repeat f=1+flr(rnd(36))until b[f]!=""b[f]=i
if(i==x)p=f
end::_::t=btnp cls()for i=0,35 do
k=b[i+1]
?k,i%9*8,6*flr(i/9)+20,k==x and 11 or 7
end b[p]=""q=p
if(t(0))q-=1
if(t(1))q+=1
if(t(2))q-=9
if(t(3))q+=9
if(b[q]and#b[q]>0)p=q t=b[p]
if(t=="⬆️"or t==v)b[p-10]=""b[p-9]=""b[p-8]=""
if(t=="⬇️"or t==v)b[p+10]=""b[p+9]=""b[p+8]=""
if(t=="⬅️"or t==h)b[p-10]=""b[p-1]=""b[p+8]=""
if(t=="➡️"or t==h)b[p+10]=""b[p+1]=""b[p-8]=""
b[p]=x flip()goto _

"Unminified" source code:

--patrick's picochallenge
--by tobiasvl

--use 64x64 resolution
poke(0x5f2c,3)

--generate a blank board of
--empty █ tiles
board={}
--the board is 7x4, but we
--represent it as a one-
--dimensional table. we also
--represent it as 36 tiles, ie
--a 9x4 grid, with two columns
--of "" on each end, so ⬅️➡️▤▥
--tiles don't wrap around when
--they destroy adjacent tiles.
for i=1,36 do
  if i%9<2 then
    --first and last column
    board[i]=""
  else
    board[i]="█"
  end
end

--populate the board with tiles
--and the player's starting tile
tiles={"⬆️","➡️","▤","⬅️","⬇️","▥","웃"}
for i in all(tiles) do
  --find a random tile which is
  --not in the "invisible" outer
  --columns
  repeat
    position=1+flr(rnd(36))
  until board[position]!=""
  board[position]=i
  --remember the player
  if (i=="웃") player=position
end

--game loop
::_::
cls()

--print the board
--here's the only obfuscation i
--left in: here i loop from
--0 to 35, instead of 1 to 36,
--because then i only need to
--do i+1 once instead of i-1
--twice.
for i=0,35 do
  local tile=board[i+1]
  --the player is green
  if tile=="웃" then
    color(11)
  else
    color(7)
  end
  --properly centering the board
  --takes up too many characters
  --so just an approximation
  print(tile,i%9*8,6*flr(i/9)+20)
end

--erase the player character
--and destroy the tile
board[player]=""
--remember the player's position
new_player=player

--move the player's position if
--an arrow key is pressed
if (btnp(⬅️)) new_player-=1
if (btnp(➡️)) new_player+=1
if (btnp(⬆️)) new_player-=9
if (btnp(⬇️)) new_player+=9

--if we're still inside the
--board proper, ie the tile isn't
--nil (outside the board) or ""
--(the border columns), make
--that the new position.
if board[new_player] and board[new_player]!="" then
  player=new_player
  tile=board[player]
end

--if the player lands on one of
--the special tiles, destroy
--adjacent tiles
if tile=="⬆️" or tile=="▥" then
  --destroy three tiles above
  board[player-10]=""
  board[player-9]=""
  board[player-8]=""
end
if tile=="⬇️" or tile=="▥" then
  --destroy three tiles below
  board[player+10]=""
  board[player+9]=""
  board[player+8]=""
end
if tile=="⬅️" or tile=="▤" then
  --destroy three tiles left
  board[player-10]=""
  board[player-1]=""
  board[player+8]=""
end
if tile=="➡️" or tile=="▤" then
  --destroy three tiles right
  board[player+10]=""
  board[player+1]=""
  board[player-8]=""
end

--put the player in the new
--(or old!) position
board[player]="웃"

--loop
flip()
goto _
P#61429 2019-02-01 08:53 ( Edited 2019-02-01 08:57)
[ :: Read More :: ]

Not a big problem, but probably easy to fix.

If you're in the sprite editor and press Alt+Left to go to the code editor, the cursor will move one space to the left.

The same happens if you're in the music editor and press Alt+Right; the cursor will move to the right.

P#61418 2019-01-31 23:26
[ :: Read More :: ]

Here's a strange bug I found. If you write something like this in the code editor:

rectfill(0,0,5,5)

and you search for 0 with CTRL+F, it will highlight the first 0. If you then press CTRL+G, however, it will fail to find the second one. The same goes for the 5.

From my testing, this seems to only happen with every other occurence. If you search for 0 here:

rectfill(0,0,0,0)

then CTRL+G will only highlight the first and the third argument.

I've only had it happen with function arguments, and only with single-character arguments; single-letter variable names also have this problem. Putting a space after the commas also makes it behave properly.

It's a bit of a problem when writing tweetcarts where you have little whitespace, short variable names, and want to find variables or number literals to replace while optimizing :)

P#61417 2019-01-31 23:23
[ :: Read More :: ]

Cart #dihobzifo-0 | 2019-01-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#61415 2019-01-31 20:56
[ :: Read More :: ]

Cart #obstacle-0 | 2019-01-31 | Embed ▽ | License: CC4-BY-NC-SA
6

P#61412 2019-01-31 19:52 ( Edited 2019-01-31 19:53)
[ :: Read More :: ]

Cart #sunrise-0 | 2019-01-31 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
6

Tweetcart, 272 chars.

Grid based on tweetcart by @electricgryphon.

P#61403 2019-01-31 18:30 ( Edited 2019-01-31 18:38)
[ :: Read More :: ]

Cart #moon_rises-1 | 2019-02-02 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Originally from Tobiasvl's tweetcart: https://twitter.com/Spug/status/1090559155436511232

(Sorry I didn't include the link before.)

P#61398 2019-01-31 18:02 ( Edited 2019-02-02 11:19)
View Older Posts